<%@ page import="util.DBUtil" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h3>我的购物车</h3>
<a href="home.jsp">继续购物</a>
<table>
    <%
        String sql="select t1.*,t2.product_name "
                +" from tb_cart as t1,tb_product as t2"
                +" where t1.product_id=t2.id"
                //+" and member_id=XXX"
                ;
        DBUtil dbUtil=new DBUtil();
        ResultSet rsCart=dbUtil.query(sql);
        while (rsCart.next()){
    %>
    <tr>
        <td> <%=rsCart.getString("product_name")%></td>
        <td>
            <input type="button" value="-">
            <%=rsCart.getString("sale_num")%>
            <input type="button" value="+">
        </td>
        <td> <%=rsCart.getString("sale_price")%></td>
        <td> <%=rsCart.getString("sale_money")%></td>
    </tr>
    <%
        }
    %>
</table>
<%//统计购物车里面，总的商品数量和总金额
    String totalNum="0",totalMoney="0.00";
    sql="select sum(sale_num) as totalNum,"
            +" sum(sale_money) as totalMoney from tb_cart"
    //+"where member_id=XXX"
    ;
    ResultSet rsTotal=dbUtil.query(sql);
    if (rsTotal.next()){
        totalNum=rsTotal.getString("totalNum");
        totalMoney=rsTotal.getString("totalMoney");
    }
%>
总数量：<font color="red"><%=totalNum%></font>
总金额：<font color="red"><%=totalMoney%></font>
<a href="cart_clear.jsp"><h5>清空购物车</h5></a>
<a href="order_add.jsp"><h5>去结算</h5></a>
</body>
</html>

